/**
 * 求购详情页
 * myDemandDetail.js
 * -----------------------------------
 * 18/11/15
 */

var
helper = require('../../../utils/helper.js');

Page({

/* ------------------------------
 页面数据
------------------------------ */
data: {hidden: 'hidden'},
/* ------------------------------
 页面加载
 ------------------------------ */
onLoad: function(opts){

  var demandId = opts.demandId;

  this.setData({demandId: demandId});

  // 更新导航标题
  helper.navTitle('求购信息');

  // 设置scroll-view高度
  helper.setScrollViewHeight(this);

  // 查询采购单数据
  this.queryDemandQuote(demandId);

},
/* ------------------------------
 每次页面显示时，刷新数据
------------------------------ */
onShow: function (){

},
/* ------------------------------
 查询采购单数据
 ------------------------------ */
queryDemandQuote: function(demandId) {

  console.log(demandId);

  helper.request({
    url: 'wx/demand/myDetail',
    data: {
      demandId: 'e0065640d355412c93947b4b8b80d47b'
    },
    success: this.bindDemand
  });
},
/* ------------------------------
 绑定数据
 ------------------------------ */
bindDemand: function(ret){

  // // 截至时间 装换
  helper.bindD2Str(ret, 'expireTime');
  helper.bindD2Str(ret, 'createTime');
  helper.bindD2Str(ret.quotes, 'createTime');

  console.log(ret);
  this.setData({ demand: ret.demand, quotes: ret.quotes })
}


})
